﻿// Author: Radu-Mihail
// Project: WebPage, File: AbstractWebPage.cs
// Namespace: WebPage, Class: AbstractWebPage
// Path: G:\Secure Project\WebCrawlerProject\WebPage
// Code lines: 156, Size of file: 4.12 KB
// Creation date: 1/12/2009 3:22 PM
// Last modified: 1/12/2009 3:43 PM

// Project: WebPage, File: FullWebPage.cs
// Namespace: WebPage, Class: FullWebPage
// Path: H:\Secure Project\WebPage\WebPage, Author: Radu-Mihail
// Code lines: 131, Size of file: 3.38 KB
// Creation date: 12/6/2008 7:42 PM
// Last modified: 12/24/2008 10:25 PM

#region Using directives
using System;
using System.Collections.Generic;
using WebPage.Client;
#endregion

namespace WebPage
{
    /// <summary>
    /// Full web page
    /// </summary>
    public abstract class AbstractWebPage
    {

        #region Protected fields
        protected bool _revisit;
        
        /// <summary>
        /// Last update
        /// </summary>
        protected DateTime _lastModifiedDate;
              
       
        /// <summary>
        /// File content
        /// </summary>
        protected byte[] _fileContent;

        /// <summary>
        /// Web page type
        /// </summary>
        protected WebPageContentType _webPageType;

        /// <summary>
        /// Redirect link
        /// </summary>
        protected string _redirectLink;

        /// <summary>
        /// Web link
        /// </summary>
        protected string _webLink;

        

        #endregion
        #region Properties
        /// <summary>
        /// Revist
        /// </summary>
        /// <returns>Bool</returns>
        public bool Revisit {
            get {
                return _revisit;
            } // get
        } // Revist
        
        /// <summary>
        /// Last update
        /// </summary>
        /// <returns>Date time</returns>
        public DateTime LastModifiedDate
        {
            get { return _lastModifiedDate; } // get
        } // LastUpdate
        /// <summary>
        /// Redirect link
        /// </summary>
        /// <returns>String</returns>
        public string RedirectLink
        {
            get { return _redirectLink; } // get
        } // RedirectLink
        /// <summary>
        /// Page link
        /// </summary>
        /// <returns>String</returns>
        public string PageLink
        {
            get { return _webLink; } // get
        } // PageLink
        /// <summary>
        /// Web page type
        /// </summary>
        /// <returns>Web page content type</returns>
        public WebPageContentType WebPageType
        {

            get { return _webPageType; } // get
        } // WebPageType


        public abstract List<string> LinkList
        {
            get;
        } // LinkList       

        #endregion
        #region Constructor
        /// <summary>
        /// Create full web page
        /// </summary>
        /// <param name="webPageLink">Web page link</param>
        protected AbstractWebPage(ref MyWebClient webClient, bool revisit)
        {
            _revisit = revisit;
            _webLink = webClient.InitialLink();
            _redirectLink = webClient.RedirectLink();
            _webPageType = (WebPageContentType)webClient.GetContentType();
            _lastModifiedDate = webClient.GetLastModifiedDate();            
            //Try to download the desired page and store the contents in a byte array
            DownloadData(webClient);
            webClient.Dispose();

        } // FullWebPage(webClient)
        #endregion
        #region Abstract Method

        /// <summary>
        /// Get page content
        /// </summary>
        /// <returns>Object</returns>
        public abstract Object GetPageContent();

        #endregion
        #region Private methods

        /// <summary>
        /// Download data
        /// </summary>
        private void DownloadData(MyWebClient downloadClient) 
        {            
            _fileContent = downloadClient.DownloadData();                        
            
        } // DownloadData(downloadClient)

        #endregion        


    } // class FullWebPage

} // namespace WebPage
